package com.baidu.controller;

import com.baidu.pojo.Assess;
import com.baidu.pojo.Orders;
import com.baidu.pojo.Ticket;
import com.baidu.service.AssessService;
import com.baidu.service.TicketService;
import com.baidu.utils.Pages;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
@RequestMapping("/adminAssess")
public class AdminAssessController {
    @Autowired
    private AssessService assessService;

    //查询全部
    @RequestMapping("/getAllAssess")
    public String getAllAssess(@RequestParam(defaultValue = "1") Integer currentPage,
                               @RequestParam(defaultValue = "3") Integer pageSize,
                               HttpServletRequest request,
                               HttpSession session){
        Pages pages=new Pages();
        pages.setCurrentPage(currentPage);
        pages.setPageSize(pageSize);
        int total=assessService.count();
        pages.setTotalCount(total);
        request.setAttribute("pages",pages);
        List<Assess> list = assessService.getByPage(pages.getCp(),pageSize);
        request.setAttribute("assess1",list);
        return "assessList";
    }
    //删除
    @RequestMapping("/delAssess")
    public String updateOrders(Integer aid){
        System.out.println("------------delAssess--------------");
        //执行修改
        assessService.deleteAssess(aid);
        return "redirect:/adminAssess/getAllAssess";
    }
}
